#include <stdio.h>
#include "driver/mouse.h"
#include "driver/vga.h"

int main()
{
    printf("Hello from Nios II!\n");
    
    const unsigned int TIMEOUT = 0xFFFF;

    Mouse& m = Mouse::create( );
    Vga& v = Vga::create( );
    
    m.init();
    v.set_resolution( 640, 480 );
    v.locate_cursor( 100, 100 );
    
    while( true )
    {
        int dir_x = 0;
        int dir_y = 0;
        
        if( m.update( TIMEOUT ) )
        {
            m.get_direction( dir_x, dir_y );
            v.move_cursor( dir_x, dir_y );
            if( m.get_status( ( Mouse::TYPE_BUTTON ) Mouse::MOUSE_LEFT ) == ( Mouse::TYPE_BUTTON_STATUS ) Mouse::BUTTON_PRESSED )
            {
                printf( "pressed\n" );
            }
        }
        else
        {
            m.init( );
        }
    }
    

  return 0;
}
